<extend name="Public:main" />
<block name="title">修改支付密码</block>
<block name="body">
<body ng-app="myApp" ng-controller="Ctrl" ng-cloak>
    <div class="nav_top flex">
        <a  href="javascript:void(0)"  onclick="window.history.go(-1)">
            <i></i>
        </a>
        <div class="flex1">
            修改支付密码
        </div>
        <a href="javascript:void(0)">
            <i></i>
        </a>
    </div>
    <div style="height: 0.44rem;"></div>
    <div class="login">
        <div>
            <label>旧支付密码</label>
            <input type="password" name="oldPasswd" placeholder="旧支付密码" maxlength="6">
        </div>
        <div>
            <label>新支付密码</label>
            <input type="password" name="newPasswd" placeholder="新支付密码" maxlength="6">
        </div>
    </div>
    <input class="login_btn" type="button" value="确认" ng-click="sub()">
    <div class="go_rf clearfix">
        <a href="javascript:void(0)">

        </a>
        <a href="{:U('Member/forget_pay')}">
            忘记支付密码？
        </a>
    </div>
</body>
    <block name="custom_js">
        <script>
            var app = getApp('myApp', []);
            app.controller('Ctrl', function ($scope, $http) {
                $scope.sub=function () {
                    $http({
                        method:'POST',
                        data:{
                            "oldPasswd" : $("input[name='oldPasswd']").val(),
                            "newPasswd" : $("input[name='newPasswd']").val(),
                        },
                        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
                        transformRequest: function(obj) {
                            var str = [];
                            for (var p in obj) {
                                str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
                            }
                            return str.join("&");
                        },
                        url: "/index.php/Home/Member/revisePayment"
                    }).then(function successCallback(response) {
                        if(response.data.code==0){
                            layer.msg(response.data.data);
                            setTimeout(function () {
                                window.location.href = '/index.php/Home/Member/index';
                            }, 1000);
                        }else {
                            layer.msg(response.data.msg)
                        }
                    }, function errorCallback(response) {
                        errorHandle(response);
                    });
                }
            });
        </script>
    </block>
</block>